/**
 * User: alesj
 * Date: 11.1.2006
 * Time: 12:26:20
 * 
 * (C) Genera Lynx d.o.o.
 */

package com.alesj.blueberry.par.lotto;

import com.alesj.blueberry.par.basic.GameObject;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.math.BigInteger;
import java.util.Map;
import java.util.Set;

/**
 * @author <a href="mailto:ales.justin@genera-lynx.com">Ales Justin</a>
 */
@Entity
@Table(name = "lotto_ticket")
public class LottoTicket extends GameObject {

    private int size;
    private BigInteger result;
    private int duplicate;

    public String info() {
        return "LT (" + getResult() + " - RE.id = " + getRequestEntry().getId() + ")";
    }

    public void fillResultMap(Map<String, Object> resultMap) {
        Set values = (Set)resultMap.get("values");
        setSize(values.size());
        BigInteger resultBI = (BigInteger)resultMap.get("result");
        setResult(resultBI);
        Integer duplicateInt = (Integer)resultMap.get("duplicate");
        setDuplicate(duplicateInt);
    }

    public String toString() {
        return info();
    }

    @Column(name = "ticket_size")
    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    @Column(name = "ticket_result")
    public BigInteger getResult() {
        return result;
    }

    public void setResult(BigInteger result) {
        this.result = result;
    }

    public int getDuplicate() {
        return duplicate;
    }

    public void setDuplicate(int duplicate) {
        this.duplicate = duplicate;
    }

}
